home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-09-06 | 2.8 KB | 133 lines | [TEXT/CWIE] |
- // ModalStuff.cp -- Modal dialog
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <TextEdit.h>
- #include <Appearance.h>
-
- #include "ResourceDefs.h"
- #include "Miscellany.h"
- #include "ControlUtils.h"
-
- #include "ModalStuff.h"
-
- #define kOKButton 1
- #define kToolsPalette 2
- #define kPopupsBox 3
- #define kFromValuesList2Popup 4
- #define kFromMenuPopup 5
- #define kListsBox 6
- #define kTextListList 7
-
-
- //----------
- // static
- Boolean CModalStuff::GetModalStuff (
- DModalStuffData* ioData)
- {
- Boolean result = false;
- CModalStuff* dialog = new CModalStuff;
-
- result = dialog->RunModal (DLOG_ModalStuff, ioData);
-
- delete dialog;
-
- return result;
- }
-
- //----------
- CModalStuff::CModalStuff ()
- {
- mData = nil;
- }
-
- //----------
- CModalStuff::~CModalStuff ()
- {
- }
-
- //----------
- void CModalStuff::FinishMake ()
- {
- mOKHandle = GetControlItem (kOKButton);
- SetDefaultState (mOKHandle, true);
- ::SetDialogDefaultItem (mDialog, kOKButton);
- mToolsHandle = GetControlItem (kToolsPalette);
- mPopupsHandle = GetControlItem (kPopupsBox);
- mFromValuesList2Handle = GetControlItem (kFromValuesList2Popup);
- mFromMenuHandle = GetControlItem (kFromMenuPopup);
- mListsHandle = GetControlItem (kListsBox);
- mTextListHandle = GetControlItem (kTextListList);
- BuildTextListList (mTextListHandle);
- }
-
- //----------
- void CModalStuff::ConnectToData (
- AMSignaler* inData)
- {
- AMDialog::ConnectToData (inData);
- mData = (DModalStuffData*) inData;
-
- SetControlValue (mToolsHandle, mData->GetTools2 ());
- SetControlValue (mFromValuesList2Handle, mData->GetFromValuesList3 ());
- SetControlValue (mFromMenuHandle, mData->GetFromMenu2 ());
- SetListBoxChoice (mTextListHandle, mData->GetTextList2 ());
- }
-
- //----------
- void CModalStuff::DataChanged (
- long inDataID)
- {
- if (inDataID == idTools2) {
- SetControlValue (mToolsHandle, mData->GetTools2 ());
- }
- if (inDataID == idFromValuesList3) {
- SetControlValue (mFromValuesList2Handle, mData->GetFromValuesList3 ());
- }
- if (inDataID == idFromMenu2) {
- SetControlValue (mFromMenuHandle, mData->GetFromMenu2 ());
- }
- }
-
- //----------
- void CModalStuff::BuildTextListList (
- ControlHandle inControl)
- {
- ListHandle list = GetListHandle (inControl);
-
- AddToList ("\pOne", list);
- AddToList ("\pTwo", list);
- AddToList ("\pThree", list);
- AddToList ("\pInfinity", list);
- }
-
-
- //----------
- void CModalStuff::DoItem (
- SInt16 inItemHit)
- {
- switch (inItemHit) {
- case kOKButton:
- SetResult (true);
- break;
- case kToolsPalette:
- mData->SetTools2 (GetControlValue (mToolsHandle));
- break;
- case kFromValuesList2Popup:
- mData->SetFromValuesList3 (GetControlValue (mFromValuesList2Handle));
- break;
- case kFromMenuPopup:
- mData->SetFromMenu2 (GetControlValue (mFromMenuHandle));
- break;
- case kTextListList:
- mData->SetTextList2 (GetListBoxChoice (mTextListHandle));
- break;
-
- } // switch
- }
-